/*
 *
 *  Copyright (C) 1997-2011, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module:  dcmjp2
 *
 *  Author:  qinwl,2017.06.27
 *
 *  Purpose: singleton class that registers encoders for all supported JPEG processes.
 *
 */

#ifndef DJP2ENCODE_H
#define DJP2ENCODE_H

#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/oftypes.h"  /* for OFBool */
#include "dcmtk/dcmdata/dctypes.h"  /* for Uint32 */
#include "dcmtk/dcmjp2/djp2define.h"

class DcmJ2KCodecParameter;
class DcmJ2KCodecEncoder;

/** singleton class that registers encoders for all supported JPEG processes.
 */
class DCMTK_DCMJP2_EXPORT DcmJ2KEncoderRegistration
{
public:

	/** registers RLE encoder.
	*  If already registered, call is ignored unless cleanup() has
	*  been performed before.
	*  @param pCreateSOPInstanceUID flag indicating whether or not
	*    a new SOP Instance UID should be assigned upon compression.
	*  @param pFragmentSize maximum fragment size (in kbytes) for compression, 0 for unlimited.
	*  @param pCreateOffsetTable create offset table during image compression?
	*  @param pConvertToSC flag indicating whether image should be converted to
	*    Secondary Capture upon compression
	*/
	static void registerCodecs(
		OFBool pCreateSOPInstanceUID = OFFalse,
		Uint32 pFragmentSize = 0,
		OFBool pCreateOffsetTable = OFTrue,
		OFBool pConvertToSC = OFFalse);

	/** deregisters encoder.
	*  Attention: Must not be called while other threads might still use
	*  the registered codecs, e.g. because they are currently encoding
	*  DICOM data sets through dcmdata.
	*/
	static void cleanup();

private:

	/// private undefined copy constructor
	DcmJ2KEncoderRegistration(const DcmJ2KEncoderRegistration&);

	/// private undefined copy assignment operator
	DcmJ2KEncoderRegistration& operator=(const DcmJ2KEncoderRegistration&);

	/// flag indicating whether the encoder is already registered.
	static OFBool registered;

	/// pointer to codec parameter
	static DcmJ2KCodecParameter *cp;

	/// pointer to RLE encoder
	static DcmJ2KCodecEncoder *codec;

};

#endif
